package com.biao.threadPool;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @description: 使juc中的ThreadPoolExecutor来做的线程池
 * @author:chenwenbiao
 * @createTime:2020/1/17 11:41
 * @Version：1.0
 **/
public class ThreadPoolUseExecutor {

    /**
     * 定好线程池，往里面放执行的代码块即可
     */
    private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(50, 100,1000L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<Runnable>());

    public static void main(String[] args) {
        for(int i = 0 ; i < 200 ; i++){
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程：" + Thread.currentThread().getName() + "的打印。");
                }
            });
        }
    }
}
